<template>
    <div class="A">
        <h1>这是AAAA</h1>
        {{Flag}}
    </div>
</template>

<script setup lang="ts">
// import Bus from '../../Bus'
// import { ref } from 'vue'
// let Flag = ref(false)
// Bus.on('on-click', (flag: boolean) => {
//     Flag.value = flag
// })

import { getCurrentInstance, ref } from 'vue'

const instance = getCurrentInstance();   // 获取当前vue实例

let Flag = ref(false)
// instance?.proxy?.$Mit.on('on-sss', (flag: boolean) => {
//     Flag.value = flag
// })
// instance?.proxy?.$Mit.on('*', (type: any, val:any) => {    // 监听多条
//     console.log(type, val);
// })

const Bus = (flag: boolean) => {
    Flag.value = flag
}
instance?.proxy?.$Mit.on('on-sss', Bus)      // 监听
instance?.proxy?.$Mit.off('on-sss', Bus)      // 移除监听

instance?.proxy?.$Mit.all.clear()      // 移除所有监听

</script>

<style scoped>
.A {
    width: 200px;
    height: 200px;
    padding: 10px;
    background-color: burlywood;
    color: white;
}
</style>